package com.lxb.store.controller;

import com.lxb.store.entity.AboutPage;
import com.lxb.store.entity.User;
import com.lxb.store.service.AboutPageService;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class AboutController {

    @Autowired
    private AboutPageService aboutPageService;

    @RequestMapping("/about")
    public String AboutIndex(Model model){

        AboutPage page = aboutPageService.getById(1);

        //获取登录用户信息
        User loginUser = (User) SecurityUtils.getSubject().getPrincipal();
        //密码设置为空
        if(loginUser != null){
            loginUser.setPassword(null);
        }
        model.addAttribute("page",page);
        model.addAttribute("user",loginUser);
        return "about";
    }
}
